<?php

require_once('../domit/xml_domit_include.php');


class menuObject{
	var $id="";
	var $port="";
	var $eng="";
}


$cdCollection =new DOMIT_Document();
$cdCollectionString = '<?xml version="1.0"?><barong>
	<menu>
		<item id="summerStage2006.php" port="SummerStage 2006" eng="SummerStage 2006" />
		<item id="guru.php" port="Guru Jazzmatazz / Veiga & Salazar" eng="Guru Jazzmatazz / Veiga & Salazar" />
		<item id="madeleine.php" port="Madeleine Peyroux no JAM" eng="Madeleine Peyroux no Brasil" />
		<item id="ilustre.php" port="Ilustre Grelha e Goró" eng="Ilustre" />
		<item id="summerjam2004.php" port="Summer Jam 2004/2005" eng="Summer Jam 2004/2005" />
		<item id="jamwarehouse.php" port="Jam Warehouse" eng="Jam Warehouse" />
	</menu>
	<home>
	<img src="http://www.barong.com.br/site/midias/summerStage2006/fundo2.jpg" />
		<frases>
			<frase color="0xffffff" lnk="summerStage2006.php" value_pt="de 27 de dezembro" value_en="de 27 de dezembro" />
			<frase color="0xffffff" lnk="summerStage2006.php" value_pt="a 28 de fevereiro" value_en="a 28 de fevereiro" />
			<frase color="0xffffff" lnk="summerStage2006.php" tam="76" value_pt="SummerStage "06" value_en="IlhaBela SummerStage 06" />
			<frase color="0x000000" lnk="summerStage2006.php" tam="26" value_pt="                              Música na Ilha" value_en="Música na Ilha" />
		</frases>
	</home>
</barong>
';

//use parseXML method to populate document
$success = $cdCollection->parseXML($cdCollectionString, true); //parse document

$menu = array();

function processMenu($cn){
	global $menu;
	if ($cn->hasChildNodes()){
		$myChildNodes =& $cn->childNodes;
		$numChildren =& $cn->childCount;
		for ($i = 0; $i < $numChildren; $i++) {
			$node = new menuObject();
			$currentNode =& $myChildNodes[$i];
			echo ("CHILD Node $i contents are: \n<br />");

			if ($currentNode->hasAttribute("id")) {
				$node->id = $currentNode->getAttribute("id");
			}
			if ($currentNode->hasAttribute("port")) {
				$node->port = $currentNode->getAttribute("port");
			}
			if ($currentNode->hasAttribute("eng")) {
				$node->eng = $currentNode->getAttribute("eng");
			}
			$menu[] = $node;
			//$currentNode->toNormalizedString(true) . "\n<br />\n<br />"

		}
	}
	echo "<PRE>";
	print_r($menu);
	echo "</PRE>";
}


if ($success) {
	//process XML
	$myDocumentElement = new DOMIT_Element("");
	$myDocumentElement = $cdCollection->documentElement;
	echo "Node name: " . $myDocumentElement->nodeName;echo "\n<br />";
	echo "Node type: " . $myDocumentElement->nodeType;echo "\n<br />";
	echo "Node value: " . $myDocumentElement->nodeValue;echo "\n<br />";


	if ($cdCollection->documentElement->hasChildNodes()) {
		$myChildNodes =& $cdCollection->documentElement->childNodes;
		$numChildren =& $cdCollection->documentElement->childCount;
		for ($i = 0; $i < $numChildren; $i++) {
			if ($currentNode->nodeName=="menu"){
				processMenu($currentNode);
			}
			$currentNode =& $myChildNodes[$i];
			echo ("Node $i contents are: \n<br />" .
			$currentNode->toNormalizedString(true) . "\n<br />\n<br />");
		}
	}
}	else {
	//an error has occurred; echo to browser
	echo "Error code: " . $cdCollection->getErrorCode();
	echo "\n<br />";
	echo "Error string: " . $cdCollection->getErrorString();
}

//require_once('somepath/xml_domit_include.php');
//$cdCollection =& new DOMIT_Document();
//$success = $cdCollection->loadXML("/xml/cdcollection.xml");
?>